package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.EnvMonitorData;
import com.ruoyi.business.service.IEnvMonitorDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * 环保监控数据Controller
 * 
 * @author qiancheng
 * @date 2025-06-13
 */
@Api(tags = "环保监控数据管理")
@RestController
@RequestMapping("/business/data")
public class EnvMonitorDataController extends BaseController
{
    @Autowired
    private IEnvMonitorDataService envMonitorDataService;

    /**
     * 查询环保监控数据列表
     */
    @ApiOperation("查询环保监控数据列表")
//    @PreAuthorize("@ss.hasPermi('business:data:list')")
    @GetMapping("/list")
    @Anonymous
    public TableDataInfo list(@ApiParam("环保监控数据查询条件") EnvMonitorData envMonitorData)
    {
        startPage();
        List<EnvMonitorData> list = envMonitorDataService.selectEnvMonitorDataList(envMonitorData);
        return getDataTable(list);
    }

    /**
     * 导出环保监控数据列表
     */
    @ApiOperation("导出环保监控数据列表")
    @PreAuthorize("@ss.hasPermi('business:data:export')")
    @Log(title = "环保监控数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, @ApiParam("环保监控数据查询条件") EnvMonitorData envMonitorData)
    {
        List<EnvMonitorData> list = envMonitorDataService.selectEnvMonitorDataList(envMonitorData);
        ExcelUtil<EnvMonitorData> util = new ExcelUtil<EnvMonitorData>(EnvMonitorData.class);
        util.exportExcel(response, list, "环保监控数据数据");
    }

    /**
     * 获取环保监控数据详细信息
     */
    @ApiOperation("获取环保监控数据详细信息")
//    @PreAuthorize("@ss.hasPermi('business:data:query')")
    @GetMapping(value = "/{id}")
    @Anonymous
    public AjaxResult getInfo(@ApiParam("监控数据ID") @PathVariable("id") Long id)
    {
        return success(envMonitorDataService.selectEnvMonitorDataById(id));
    }

    /**
     * 新增环保监控数据
     */
    @ApiOperation("新增环保监控数据")
//    @PreAuthorize("@ss.hasPermi('business:data:add')")
    @Anonymous
    @Log(title = "环保监控数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@ApiParam("环保监控数据信息") @RequestBody EnvMonitorData envMonitorData)
    {
        return toAjax(envMonitorDataService.insertEnvMonitorData(envMonitorData));
    }

    /**
     * 修改环保监控数据
     */
    @ApiOperation("修改环保监控数据")
    @PreAuthorize("@ss.hasPermi('business:data:edit')")
    @Log(title = "环保监控数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@ApiParam("环保监控数据信息") @RequestBody EnvMonitorData envMonitorData)
    {
        return toAjax(envMonitorDataService.updateEnvMonitorData(envMonitorData));
    }

    /**
     * 删除环保监控数据
     */
    @ApiOperation("删除环保监控数据")
    @PreAuthorize("@ss.hasPermi('business:data:remove')")
    @Log(title = "环保监控数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@ApiParam("监控数据ID数组") @PathVariable Long[] ids)
    {
        return toAjax(envMonitorDataService.deleteEnvMonitorDataByIds(ids));
    }
}
